# Compiler
CC := gcc

# Normal compiler flags.
CFLAGS := -Wall -Wunreachable-code

# Debugging.
#CFLAGS += -ggdb

# Solaris is actually kinda different from the GNU systems,
# in terms of libraries needed and extra CFLAGS.
ifeq ($(shell uname),SunOS)
# We need to do things slightly different on Solaris.
CFLAGS += -DSOLARIS
# We assume this is the first serial port.
CFLAGS += -DDEFAULT_SERIAL=\"/dev/ttya\"
# No extra libs.
LIBS :=
else
# Libraries
LIBS := -lutil
# We want X/Open stuffs.
CFLAGS += -D_XOPEN_SOURCE
# /dev/ttyS0 is the first serial port we'll assume.
CFLAGS += -DDEFAULT_SERIAL=\"/dev/ttyS0\"
endif

%.o: %.c
	$(CC) $(CFLAGS) -c -o $@ $<

kdmx2: kdmx2.o $(PTY)
	$(CC) -o $@ kdmx2.o $(LIBS)

clean:
	rm -f *.o kdmx2
